#ifndef __IC_HEAD

extern "C"
{


	HANDLE __stdcall IC_InitComm(__int16 Port);
	HANDLE __stdcall IC_InitPort(__int16 Port,unsigned long baud);
__int16 __stdcall IC_ExitComm(HANDLE ICDev);
__int16 __stdcall IC_Down(HANDLE ICDev);
__int16 __stdcall IC_Status(HANDLE ICDev);
int __stdcall IC_DevBeep(HANDLE icdev,int time);
int __stdcall IC_CheckCard(HANDLE icdev);
__int16 __stdcall IC_Write (HANDLE ICDev, __int16 Offset,__int16 len, unsigned char* DataBuffer);
__int16 __stdcall IC_Write_SSF1101 (HANDLE ICDev, long Offset,long len, unsigned char* DataBuffer);
__int16 __stdcall IC_Write_Float(HANDLE idComDev,__int16 Offset,float fdata);
__int16 __stdcall IC_Write_Int (HANDLE idComDev,__int16 Offset,int idata);
__int16 __stdcall IC_Read (HANDLE ICDev,__int16 Offset,__int16 len, unsigned char * DataBuffer);
__int16 __stdcall IC_Read_SSF1101 (HANDLE ICDev,long Offset,long len, unsigned char * DataBuffer);
__int16 __stdcall IC_Read_Float(HANDLE ICDev,__int16 Offset,float& fdata);
__int16 __stdcall IC_Read_Int(HANDLE ICDev,__int16 Offset,int& idata);
__int16 __stdcall IC_Encrypt(char *key,char *ptrsource,unsigned __int16 msglen , char * ptrdest);
__int16 __stdcall IC_Decrypt(char *key,char ptrsource,unsigned __int16 msglen, char *ptrdest); 
HANDLE __stdcall IC_InitCommAdvanced(__int16 Port);
__int16 __stdcall IC_Erase(HANDLE ICDev,__int16 Offset,__int16 len);
__int16 __stdcall IC_Erase_SSF1101(HANDLE ICDev);
__int16 __stdcall IC_WriteProtection (HANDLE ICDev, __int16 Offset, __int16 len,unsigned char *ProtBuffer);
__int16 __stdcall IC_ReadProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer);
__int16 __stdcall tea(unsigned long *k, long N,unsigned long key,unsigned long key1) ;	
					   
///////////////////////////// operate Device ////////////////////////////
int __stdcall IC_ReadVer(HANDLE icdev,unsigned char *data_buff);				//读取硬件版本号
int __stdcall ReadDevicepassword(HANDLE icdev,unsigned char *buffer);      //读设备密码
int __stdcall WriteDevicepassword(HANDLE icdev,unsigned char* buffer);     //修改密码
int __stdcall Deviencrypt(HANDLE icdev,unsigned char buffer);              //设备加密函数 
int __stdcall Check_Deviencrypt(HANDLE icdev,unsigned char *restart);      //核对设备密码
int __stdcall Check_Disencrypt(HANDLE icdev,unsigned char *restart);       //检查设备密码是否有效
int __stdcall IC_WriteDevice(HANDLE icdev,int offset,int length,unsigned char* buffer);
int __stdcall IC_ReadDevice(HANDLE icdev,int offset,int length,unsigned char *buffer);

///////////////////////////24Cxx/64 函数/////////////////////
__int16 __stdcall IC_Check_24Cxx(HANDLE ICDev,unsigned char* cardType);
__int16	__stdcall IC_Choose_24Cxx(HANDLE ICDev);
__int16 __stdcall IC_Check_24C64(HANDLE ICDev);
__int16	__stdcall IC_Choose_24C64(HANDLE ICDev);

///////////////////////////SSF1101 函数/////////////////////
__int16 __stdcall IC_Check_SSF1101(HANDLE ICDev);
__int16	__stdcall IC_Choose_SSF1101(HANDLE ICDev);
					
///////////////////////////45DB041 函数/////////////////////
__int16	__stdcall IC_Choose_45DB041(HANDLE ICDev);
__int16 __stdcall IC_Check_45DB041(HANDLE ICDev);
__int16 __stdcall IC_DirectWrite(HANDLE idComDev, int page, int offset,int bytes, unsigned char *buff);
__int16 __stdcall IC_DirectRead(HANDLE idComDev,int page,int offset,int bytes, unsigned char *buff);
__int16 __stdcall IC_ReadPage_45DB041(HANDLE ICDev,const int stPage,int slen,const int offset,unsigned char *rData);										//读若干个页的数据
__int16 __stdcall IC_WritePage_45DB041(HANDLE ICDev,const int stPage,const int cntPage,const unsigned char* wData);							//写若干个页的数据			
					  
///////////////////////////4442 函数/////////////////////					  
__int16 __stdcall IC_Check_4442 (HANDLE ICDev);
__int16	__stdcall IC_Choose_4442(HANDLE ICDev);
__int16 __stdcall IC_ReadCount_SLE4442 (HANDLE ICDev);
__int16 __stdcall IC_ReadPass_SLE4442 (HANDLE ICDev, unsigned char* Password);
__int16 __stdcall IC_CheckPass_SLE4442 (HANDLE ICDev, unsigned char* Password);
__int16 __stdcall IC_ChangePass_SLE4442 (HANDLE ICDev, unsigned char* Password);
__int16 __stdcall IC_WriteProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer);
__int16 __stdcall IC_ReadProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer);

///////////////////////////4428 函数/////////////////////					  
__int16 __stdcall IC_Check_4428 (HANDLE ICDev);
__int16	__stdcall IC_Choose_4428(HANDLE ICDev);
__int16 __stdcall IC_ReadCount_SLE4428 (HANDLE ICDev);
__int16 __stdcall IC_CheckPass_SLE4428 (HANDLE ICDev, unsigned char* Password);
__int16 __stdcall IC_ChangePass_SLE4428 (HANDLE ICDev, unsigned char* Password);
__int16 __stdcall IC_WriteProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer);
__int16 __stdcall IC_ReadProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer);

///////////////////////////CPU 函数/////////////////////
__int16 __stdcall IC_Check_CPU(HANDLE ICDev);																	//检测卡
__int16	__stdcall IC_Choose_Cpu(HANDLE ICDev);																//发送卡型
__int16 __stdcall SetCardSeat(long DevID,int seatType);														//设置卡座类型
__int16 __stdcall IC_CpuReset(HANDLE ICDev,unsigned char *rlen, unsigned char *rbuff); // CPU复位
__int16 __stdcall IC_SetBaud(HANDLE ICDev,int baud);//设置端口号
__int16 __stdcall IC_CpuApdu(HANDLE ICDev,int slen,unsigned char * sbuff,int *rlen,unsigned char * rbuff);																	//交换数据
__int16 __stdcall IC_CpuApduSource(HANDLE ICDev,unsigned char slen,unsigned char * sbuff,unsigned char *rlen,unsigned char * rbuff);	//交换数据
__int16 __stdcall IC_CpuSetProtocol(HANDLE ICDev,unsigned char prtol);				//设置接口
__int16 __stdcall IC_CpuGetProtocol(HANDLE ICDev);														//获取接口
__int16 __stdcall IC_SetCpuPara(HANDLE idComDev,unsigned char cputype,unsigned char cpupro,unsigned char cpuetu);


/////////////////////////// 102 函数 ////////////////////
__int16 __stdcall IC_Choose_102(HANDLE ICDdev);
__int16 __stdcall IC_Check_102 (HANDLE ICDev);
__int16 __stdcall IC_ReadErrorCnt_102(HANDLE ICDdev,unsigned char* cntError);//读错误计数
__int16 __stdcall IC_CheckUserCode_102(HANDLE ICDdev,unsigned char* key);    //验证用户密码 注：这个函数为102、1604、1604B共用
__int16 __stdcall IC_CheckFuseCode_102(HANDLE ICDdev,int iZone,unsigned char* key);        //验证区密码    iZone为区序号：取值1、2
__int16 __stdcall IC_ChangeUserCode_102(HANDLE ICDdev,unsigned char* key);   //修改用户密码
__int16 __stdcall IC_ChangeFuseCode_102(HANDLE ICDdev,int iZone,unsigned char* key);       //修改区密码    iZone为区序号：取值1、2
__int16 __stdcall IC_Fuse_102(HANDLE ICDdev);                                //熔断
//========自定义函数（不输出）=====
__int16 __stdcall CheckCode102(HANDLE ICDdev,unsigned char* addr,unsigned char* key,int keylen);
__int16 __stdcall Changekey102(HANDLE ICDdev,unsigned char* addr,unsigned char* key,int keylen);

/////////////////////////// 1604 函数 ////////////////////
__int16 __stdcall IC_Choose_1604(HANDLE ICDdev);                              //发送卡型
__int16 __stdcall IC_Check_1604 (HANDLE ICDev);                               //测卡
__int16 __stdcall IC_ReadErrorCnt_1604(HANDLE ICDdev,unsigned char* cntError);//读错误计数
__int16 __stdcall IC_CheckUserCode_1604(HANDLE ICDdev,unsigned char* key);    //验证用户密码
__int16 __stdcall IC_CheckZoneCode_1604(HANDLE ICDdev,int iZone,unsigned char* key);        //验证区密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_CheckFuseCode_1604(HANDLE ICDdev,int iZone,unsigned char* key);        //核对区擦除密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_ChangeUserCode_1604(HANDLE ICDdev,unsigned char* key);   //修改用户密码
__int16 __stdcall IC_ChangeZoneCode_1604(HANDLE ICDdev,int iZone,unsigned char* key);       //修改区密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_ChangeFuseCode_1604(HANDLE ICDdev,int iZone,unsigned char* key);       //修改区擦除密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_Fuse_1604(HANDLE ICDdev);                                //熔断

/////////////////////////// 1604B 函数 ////////////////////
__int16 __stdcall IC_Choose_1604B(HANDLE ICDdev);
__int16 __stdcall IC_Check_1604B(HANDLE ICDev);
__int16 __stdcall IC_ReadErrorCnt_1604B(HANDLE ICDdev,unsigned char* cntError);//读错误计数
__int16 __stdcall IC_CheckUserCode_1604B(HANDLE ICDdev,unsigned char* key);    //验证用户密码
__int16 __stdcall IC_CheckZoneCode_1604B(HANDLE ICDdev,int iZone,unsigned char* key);        // 验证区密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_CheckFuseCode_1604B(HANDLE ICDdev,int iZone,unsigned char* key);														 //核对区擦除密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_ChangeUserCode_1604B(HANDLE ICDdev,unsigned char* key);   //修改用户密码
__int16 __stdcall IC_ChangeZoneCode_1604B(HANDLE ICDdev,int iZone,unsigned char* key);													 //修改区密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_ChangeFuseCode_1604B(HANDLE ICDdev,int iZone,unsigned char* key);													 //修改区擦除密码    iZone为区序号：取值1 ~ 4
__int16 __stdcall IC_Fuse_1604B(HANDLE ICDdev);								    //熔断

///////////////////////////93C46A 函数 ////////////////////
__int16 __stdcall IC_Choose_93C46A(HANDLE ICDev);
__int16 __stdcall IC_Check_93C46A(HANDLE ICDev);

/////////////////////////// 自定义函数  /////////////////////
__int16 __stdcall asc2hex(unsigned char *strasc,unsigned char *strhex,__int16 length);//acs转16进制
__int16 __stdcall hex2asc(unsigned char *strhex,unsigned char *strasc,__int16 length);//16进制转acs
}

#define  __IC_HEAD
#endif